#include <bits/stdc++.h>
// 2025/05/09
// tag: 
// Author: Forever
using namespace std;
using int64 = int64_t;

const int N = 40001;
vector<int> pri;
bool not_prime[N];
int phi[N], n, ans = 3;

void pre(int n)
{
    phi[1] = 1;
    for (int i = 2; i <= n; i++) {
        if (!not_prime[i]) {
            pri.push_back(i);
            phi[i] = i - 1;
        }
        for (int pri_j : pri) {
            if (i * pri_j > n)
                break;
            not_prime[i * pri_j] = true;
            if (i % pri_j == 0) {
                phi[i * pri_j] = phi[i] * pri_j;
                break;
            }
            phi[i * pri_j] = phi[i] * phi[pri_j];
        }
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    if (n == 1){
        cout << 0 << endl;
        return 0;
    }
    pre(n);
    for (int i = 2; i < n; i++)
        ans += phi[i] * 2;
    cout << ans << endl;
    return 0;
}